#include <avr/io.h>
#include "key.h"
#include "global.h"
#include "OLED.h"
#include "spi.h"
#include "ui.h"

void hw_init(void)
{
	DFLLRC32M.CTRL = 0;
	
	CCP = CCP_IOREG_gc; //Security Signature to modify clock 
	CLK.CTRL = CLK_SCLKSEL_RC2M_gc; // Run at 2M

	OSC.CTRL = OSC_RC2MEN_bm;
}

int main (void)
{
	hw_init();
	spi_init();
	OLED_Init();
	key_init();
	ui_init();

	while(1) {
		ui_task();
		short_delay();
	}
}
